package com.zl.tby.screen.vo.mountains;

import com.zl.tby.core.base.util.ToolsUtil;
import lombok.Data;
import com.zl.tby.core.base.util.PgMountains;

import java.util.List;
import java.util.Map;

/**
 * 上报时间统计bean
 * @author changpeng
 * @version 1.0
 * @since 2024/10/26 19:51
 */
@Data
public class TbyReportEventBean {
    /**毁坏林地*/
    private Long woodland;
    /**毁坏林木*/
    private Long forest;
    /**森林防火*/
    private Long fireproof;
    /**野生动植物*/
    private Long animalsPlants;
    /**有害生物*/
    private Long pest;
    /**自然灾害*/
    private Long naturalDisaster;
    /**核实无异常*/
    private Long noError;

    public TbyReportEventBean() {
        this.woodland = 0L;
        this.forest = 0L;
        this.fireproof = 0L;
        this.animalsPlants = 0L;
        this.pest = 0L;
        this.naturalDisaster = 0L;
    }

    public static Long count(PgMountains db, String tableName, String where, List<Object> params) {
        StringBuilder builder = new StringBuilder();
        builder.append("select count(id) as cnum from xh_yw.").append(tableName).append(where);
        List<Map<String, Object>> dataList = db.queryMap(builder.toString(), params);
        if (dataList != null && dataList.size() > 0) {
            return ToolsUtil.toLong(dataList.get(0).get("cnum") + "", 0L);
        }
        return 0L;
    }
}
